/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
   this file is part of rcssserver3D
   Fri May 9 2003
   Copyright (C) 2003 Koblenz University
   $Id$

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// -*- C++ -*- generated by wxGlade 0.4.1 on Fri Feb 23 21:06:30 2007
#ifndef KINEMATICFRAME_H
#define KINEMATICFRAME_H

#include <wx/wx.h>
#include <zeitgeist/leaf.h>

namespace oxygen
{
    class Joint;
}

class kinematicFrame: public wxFrame {
public:
    enum EControlMode
    {
        CM_PASSIV,
        CM_ACTIVE
    };

    struct JointControl
    {
    public:
        int type;
        int axis;
        boost::weak_ptr<zeitgeist::Leaf> joint;

        EControlMode mode;
        int target;

    public:
        JointControl()
            : type(0), axis(0), mode(CM_PASSIV), target(0)
        {
        }
    };

    typedef std::map<wxSlider*, JointControl> TJointControlMap;

public:
    kinematicFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition,
                   const wxSize& size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE);
    virtual ~kinematicFrame();

    /** set the parent node */
    void SetParent(boost::weak_ptr<zeitgeist::Leaf> parent);

    /** update the cached reference to the parent and recreate
        kinematic controls
    */
    void UpdateCached();

    /** update the joint sliders */
    void RefreshProperties();

protected:
    int GetParamVel(int axis) const;

    void AddJointDescription(boost::shared_ptr<oxygen::Joint> joint);
    void AddJointControl(boost::shared_ptr<oxygen::Joint> joint, int axis);

    void OnSliderChanged(wxCommandEvent& event);
    void OnScrollChanged(wxScrollEvent& event);

    float GetJointVel(float diff);
    void MoveJoint(JointControl& entry);

protected:
    DECLARE_EVENT_TABLE()

    zeitgeist::Leaf::CachedPath<zeitgeist::Leaf> mParent;
    wxScrolledWindow* mCtrScrollWnd;
    TJointControlMap mJoints;

    wxBitmap mBmpUniversal;
    wxBitmap mBmpSlider;
    wxBitmap mBmpHinge;

}; // wxGlade: end class

#endif // KINEMATICFRAME_H
